package com.wanhe.base.util;//package com.tool.lib;
//
//import android.content.Context;
//import android.database.sqlite.SQLiteDatabase;
//
//
//
//
///**
// * Created by Administrator on 2017/3/30.
// */
//
//public class DBManager {
//    private final static String dbName = "green_dao_db";
//    private static DBManager mInstance;
//    private DaoMaster.DevOpenHelper openHelper;
//    private Context context;
//
//    public DBManager(Context context) {
//        this.context = context;
//        openHelper = new DaoMaster.DevOpenHelper(context, dbName, null);
//    }
//
//    /**
//     * 获取单例引用
//     *
//     * @param context
//     * @return
//     */
//    public static DBManager getInstance(Context context) {
//        if (mInstance == null) {
//            synchronized (DBManager.class) {
//                if (mInstance == null) {
//                    mInstance = new DBManager(context);
//                }
//            }
//        }
//        return mInstance;
//    }
//
//
//    /**
//     * 获取可读数据库
//     */
//    private SQLiteDatabase getReadableDatabase() {
//        if (openHelper == null) {
//            openHelper = new DaoMaster.DevOpenHelper(context, dbName, null);
//        }
//        SQLiteDatabase db = openHelper.getReadableDatabase();
//        return db;
//    }
//
//    /**
//     * 获取可写数据库
//     */
//    private SQLiteDatabase getWritableDatabase() {
//        if (openHelper == null) {
//            openHelper = new DaoMaster.DevOpenHelper(context, dbName, null);
//        }
//        SQLiteDatabase db = openHelper.getWritableDatabase();
//        return db;
//    }
//
////    /**
////     * 插入一条记录
////     *
////     * @param user
////     */
////    public void insertUser(User user) {
////        DaoMaster daoMaster = new DaoMaster(getWritableDatabase());
////        DaoSession daoSession = daoMaster.newSession();
////        UserDao userDao = daoSession.getUserDao();
////        userDao.insert(user);
////    }
////
////    /**
////     * 插入用户集合
////     *
////     * @param users
////     */
////    public void insertUserList(List<User> users) {
////        if (users == null || users.isEmpty()) {
////            return;
////        }
////        DaoMaster daoMaster = new DaoMaster(getWritableDatabase());
////        DaoSession daoSession = daoMaster.newSession();
////        UserDao userDao = daoSession.getUserDao();
////        userDao.insertInTx(users);
////    }
////
////    /**
////     * 查询用户列表
////     */
////    public List<User> queryUserList() {
////        DaoMaster daoMaster = new DaoMaster(getReadableDatabase());
////        DaoSession daoSession = daoMaster.newSession();
////        UserDao userDao = daoSession.getUserDao();
////        QueryBuilder<User> qb = userDao.queryBuilder();
////        List<User> list = qb.list();
////        return list;
////    }
////
////    /**
////     * 查询用户列表
////     */
////    public List<User> queryUserList(int age) {
////        DaoMaster daoMaster = new DaoMaster(getReadableDatabase());
////        DaoSession daoSession = daoMaster.newSession();
////        UserDao userDao = daoSession.getUserDao();
////        QueryBuilder<User> qb = userDao.queryBuilder();
////        qb.where(UserDao.Properties.Age.gt(age)).orderAsc(UserDao.Properties.Age);
////        List<User> list = qb.list();
////        return list;
////    }
//}
